package com.liws.hellofeiginclient.sentinel;

import com.liws.hellocommon.entity.Person;
import com.liws.hellofeiginclient.feigin.ProductClient;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author: liweisheng
 * @Dcscription:
 * @Date: 2021/11/22 16:23
 */
@Component
@Slf4j
public class ProductClientFallbackFactory implements FallbackFactory<ProductClient> {
    @Override
    public ProductClient create(Throwable throwable) {

        return new ProductClient() {
            @Override
            public String getFeiginByName(String name) {
                log.error("getFeiginByName()方法异常，原因：","",throwable);
                return "getFeiginByName()方法异常";
            }

            @Override
            public List<Person> postFeiginByObject(Person person) {
                log.error("postFeiginByObject()方法异常，原因：","",throwable);
                return null;
            }
        };
    }
}
